#pragma once



const int SEQUARE_NUM = 3;
const int IMAGE_NUM = 7;
typedef int GAME_COLOR;

typedef struct tetris_sequare  
{
	tetris_sequare(){
		x=y=v=0;cf=FALSE;
	}
	GAME_COLOR color[SEQUARE_NUM];
	void Create();
	void ChangeDown();
	void ChangeUp();
	void Up();
	void Left();
	void Right();
	BOOL IsCreate(){return cf;}
	void Clear(){
		x=y=v=0;cf=FALSE;
	}
	
	int x;
	int y;
	int v;
	int xx;
	int yy;
	BOOL cf;
	static int total[3];

	void Backup(){xx=x;yy=y;}
	void AddSpeed(){v+=3;}
	void SubSpeed(){v-=3;}
	void SetXY(int,int);
}GAME_SEQUARE;

class GameLogic
{
public:
	GameLogic(void);
	GameLogic(int,int);
	~GameLogic(void);
public:
	void Generate();
	void ChangeDown();
	void ChageUp();
	void Left();
	void Right();
	GAME_CODE Timer();
	void Up();
	void AddSpeed(){m_sequare.AddSpeed();}
	void SubSpeed(){m_sequare.SubSpeed();}
	void Init();
	void IntegralAll(int);
	int Index(int i,int j){
		return i*num_y + j;
	}
	BOOL IsFaild();
	void Clear(int);
	GAME_CODE GoonClear();
	int GetX(){return m_sequare.x;}
	int GetY(){return m_sequare.y;}
	int GetPreX(){return m_sequare.xx;}
	int GetPreY(){return m_sequare.yy;}
	void SetData(const GAME_SEQUARE &);
	static const int num_x = 18;
	static const int num_y = 9;
	int* GetData(){return m_data[0];}
	GAME_COLOR GetColor(int i){
		return m_sequare.color[i] - 1;
	}
	const GAME_SEQUARE& GetNextSequare()const{
		return m_sequare_next;
	}
	int GetIntegral()const{return m_integral;}
	GAME_CODE GetState()const{return m_state;}
private:
	GAME_CODE m_state;
	int m_integral;
	GAME_SEQUARE m_sequare;
	GAME_SEQUARE m_sequare_next;

	int row;
	int column;
	int m_data[num_x][num_y];
};
